package com.zjitc.controller;

import com.zjitc.po.Country;
import com.zjitc.service.CountryService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/26 14:21
 * @description:
 */
@Controller
public class CountryController {
    @Autowired
    private CountryService countryService;
    @RequestMapping("findAll")
    public void findCountries(){
      List<Country> countries=countryService.findAllCountries();
      StringBuilder builder=new StringBuilder();
      for (Country country:countries){
        builder.append(country.toString());
        builder.append("\n");
      }
        System.out.println(builder);
    }
    @RequestMapping("/findPage")
    public void findPageCountries(
        @RequestParam(name = "start",required = false,defaultValue = "1")int start,
        @RequestParam(name = "start",required = false,defaultValue = "5")int count)

    {
    List<Country> counties=countryService.findCountries(start, count);
    StringBuilder builder=new StringBuilder();
    for (Country country:counties){
      builder.append(country.toString());
      builder.append("\n");
    }
      System.out.println(builder);
  }

}
